/**
 * ...
 * @author Thot
 */

window.onload = function()
{
	document.getElementById("test1").onclick = test1;
	document.getElementById("test2").onclick = test2;
	document.getElementById("test3").onclick = test3;
	document.getElementById("test4").onclick = test4;
};

function _zorder( p_a, p_b )
{
	return ( p_a.z < p_b.z ) ? -1 : 1;
}

function test1()
{
	var tab = new Array();
	var max = parseInt(document.getElementById("tabSize").value) ;
	
	while( --max > -1 )
	{
		tab[max] = ( ( Math.random() * 10000000 ) ) >> 0;
	}
	
	var time = new Date().getTime();
	Radix.sortInt(tab);
	time = new Date().getTime() - time;
	document.getElementById("time").value = time;
}

function test2()
{
	var tab = new Array();
	var max = parseInt(document.getElementById("tabSize").value) ;
	
	while( --max > -1 )
	{
		tab[max] = {"z":(( ( Math.random() * 10000000 ) - 5000000 ) >> 0)};
	}
	
	var time = new Date().getTime();
	Radix.sortByProperty(tab,"z");
	time = new Date().getTime() - time;
	document.getElementById("time").value = time;
}
 
function test3()
{
	var tab = new Array();
	var max = parseInt(document.getElementById("tabSize").value) ;
	
	while( --max > -1 )
	{
		tab[max] = ( ( Math.random() * 10000000 ) ) >> 0;
	}
	
	var time = new Date().getTime();
	tab.sort();
	time = new Date().getTime() - time;
	document.getElementById("time").value = time;
}
 
function test4()
{
	var tab = new Array();
	var max = parseInt(document.getElementById("tabSize").value) ;
	
	while( --max > -1 )
	{
		tab[max] = {"z":(( ( Math.random() * 10000000 ) - 5000000 ) >> 0)};
	}
	
	var time = new Date().getTime();
	tab.sort( _zorder );
	time = new Date().getTime() - time;
	document.getElementById("time").value = time;
}